package com.atguigu.java4;

public class Account {

		private int id;//账号id
		private double balance;//账号对应余额
		private double annualInterestRate;//年利率
		
		public Account(){
			
		}
		
		public Account(int id, double balance, double annualInterestRate){
			this.id = id;
			this.balance = balance;
			this.annualInterestRate = annualInterestRate;
		}
		//getter和setter方法
		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}

		public double getBalance() {
			return balance;
		}

		public void setBalance(double balance) {
			this.balance = balance;
		}

		public double getAnnualInterestRate() {
			return annualInterestRate;
		}

		public void setAnnualInterestRate(double annualInterestRate) {
			this.annualInterestRate = annualInterestRate;
		}
		
		//取钱
		public void withdraw(double amount){
			//在提款方法中要判定余额是否满足。
			if(this.balance - amount < 0){
					System.out.println("您的余额不足，请重新输入。");
			}else{
					//this.balance = this.balance - amount;//太繁琐
					balance -= amount;
					System.out.println("成功取出：" + amount );
			}
		}
		
		//存钱
		public void deposit(double amount){
			//this.balance = this.balance + amount;
			balance += amount;
			System.out.println("成功存入：" + amount );
		}
		
}
